<?xml version="1.0" encoding="utf-8"?>
<process version="1" name="Sub" xmlns="http://www.nginn.org/WorkflowDefinition.1_0.xsd" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <dataTypes>
    </dataTypes>
    <variables>
		<variable name="userName" type="string" required="true" dir="In" />
		<variable name="userId" type="int" required="true" dir="Out" />
    </variables>
	<onEnableScript>
		if data.userName == 'zenek':
			raise 'Zenka nie lubimy'
		end
	</onEnableScript>
    <body>
        <places>
            <place id="start" type="Start" />
            <place id="end" type="End" />
        </places>
        <tasks>
            <task id="T1" type="Timer">
				<variables>
					<variable name="uid" type="int" required="true" dir="Out">
						<defaultValue>666</defaultValue>
					</variable>
				</variables>
				<outputBindings>
					<bind variable="userId">
						<expr>data.uid</expr>
					</bind>
				</outputBindings>
				<parameters>
					<param variable="DelayAmount"><expr>TimeSpan.FromMinutes(2)</expr></param>
				</parameters>
            </task>
            <task id="T2" type="ReceiveMessage">
				<outputBindings>
					<bind variable="userId">
						<expr>999</expr>
					</bind>
				</outputBindings>
				<parameters>
					<param variable="MessageCorrelationId"><expr>taskInstance.ProcessInstanceId + '.T2'</expr></param>
				</parameters>
            </task>
			<task id="T3" type="Timer" label="Multi-instance timer">
				<variables>
					<variable name="tnum" type="int" dir="In" required="true" />
				</variables>
				<inputBindings>
					<bind variable="tnum"><expr>data.taskNum</expr></bind>
				</inputBindings>
				<outputBindings>
				</outputBindings>
				<multiInstanceBinding>
                    <splitExpression>range(10)</splitExpression>
					<itemAlias>taskNum</itemAlias>
                </multiInstanceBinding>
				<parameters>
					<param variable="DelayAmount"><expr>TimeSpan.FromSeconds(10 + 20 * Convert.ChangeType(data.tnum, int))</expr></param>
				</parameters>
            </task>
        </tasks>
        <flows>
            <flow from="start" to="T1" />
            <flow from="start" to="T2" />
			<flow from="start" to="T3" />
            <flow from="T1" to="end" />
            <flow from="T2" to="end" />
			<flow from="T3" to="end" />
        </flows>
    </body>
</process>